package com.gao.mq.constant;

public class Constants {

    public static final class RedisMsgKey {
        private static final String REDIS_MSG_KEY = "MQ:";

        public static String REDIS_MSG_KEY(Integer id) {
            return REDIS_MSG_KEY + id;
        }
    }

    public enum MessageType {

        /**
         * 短信消息
         */
        SMS(1, "短信消息", "sms"),

        /**
         * 邮件消息
         */
        EMAIL(2, "邮件消息", "email");

        private Integer code;
        private String desc;
        private String type;

        MessageType(Integer code, String desc, String type) {
            this.code = code;
            this.desc = desc;
            this.desc = type;
        }

        public Integer getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public String getType() {
            return type;
        }

        /**
         * 通过code获取 desc
         * @param code
         * @return
         */
        public static MessageType getEnumByCode(Integer code) {
            MessageType[] values = values();
            for (MessageType value : values) {
                if (value.getCode().equals(code)) {
                    return value;
                }
            }
            return null;
        }
    }


    public enum SmsResp {
        /**
         * 返回 OK 调用成功
         */
        SUCCESS("OK", "调用成功");

        private String code;
        private String desc;

        SmsResp(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public String getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }
    }
}
